package ch.manage.movie.downloader;

public class URLConstructor {
	
	public static String construct(String movieName,MovieDownloadPages downloadPage){
		String ret = null;
		
		switch(downloadPage){
		case HD_Area:
			ret = "http://www.hd-area.org/?s=search&q="+splitMovieName(movieName,"+");
			break;
		case HD_World:
			ret = "http://hd-world.org/index.php?s="+splitMovieName(movieName,"+");;
		}
		
		return ret;
	}
	
	
	private static String splitMovieName(String movieName, String delimiter){
		String[] movieNameSplitted = movieName.split(" ");
		StringBuilder b = new StringBuilder();
		
		for(int i = 0; i < movieNameSplitted.length;++i){
			b.append(movieNameSplitted[i]);
			if(i < movieNameSplitted.length-1){
				b.append("+");
			}
		}
		
		return b.toString();
	}
	
	public static void main(String[] args){
		System.out.println(URLConstructor.construct("Indiana Jones und der Tempel des Todes", MovieDownloadPages.HD_Area));
	}

}
